package com.yociyy.security.properties;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author: YoCiyy
 * @date: 2020/7/1
 */
@RefreshScope
@Slf4j
public class PermitUrlProperties {

	private static final String[] ENDPOINTS = {
			// oauth2默认端点 相关
			"/oauth/**",
			// swagger2默认端点 相关
			"/*/v2/api-docs", "/swagger/api-docs", "/swagger-ui.html", "/swagger-resources/**", "/webjars/**",
			// 断点监控 相关
			"/actuator/**",
			// 数据库监控 相关
			"/druid/**"
	};

	@Getter
	@Setter
	private Boolean enable = true;

	@Setter
	private List<String> urls = new ArrayList<String>();

	public List<String> getUrls() {
	    log.info(urls.toString());
		List<String> endpointList = Arrays.asList(ENDPOINTS);
		if (urls.size() <= 0) {
			return endpointList;
		}
		urls.addAll(endpointList);
		return urls;
	}

}
